package com.chat.system.controller;

import com.chat.system.entity.domain.Res;
import com.chat.system.entity.dto.UserLoginDTO;
import com.chat.system.service.IAuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.ProviderManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/auth")
public class AuthController {

    @Autowired
    IAuthService authService;
    @PostMapping("login")
    public Res login(@RequestBody UserLoginDTO loginDTO) {
        String token = authService.login(loginDTO);
        final Res success = Res.success();
        success.put("token",token);
        return success;
    }
}
